package offer;

/**
 * @Author Elephas
 * @Date 2022/1/13
 **/
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
public class ListNode {
    public int val;
    public ListNode next;
    ListNode(int x) { val = x; }

    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
    public static ListNode ListNode(int[] vals){
        if(vals.length == 0){
            return null;
        }
        ListNode head = new ListNode(vals[0],null);
        ListNode tail = head;
        for (int i = 1; i < vals.length; i++) {
            ListNode temp = new ListNode(vals[i],null);
            tail.next = temp;
            tail = temp;
        }
        tail.next = null;
        return head;
    }



}